﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace MDX_Studio_v2
{
	public partial class PerfmonWindow : DockContent
	{
		private Context _Context;
		public Context Context
		{
			set
			{
				_Context = value;
				UpdateDiplay();
			}
		}

		public PerfmonWindow()
		{
			InitializeComponent();
		}

		private void UpdateDiplay()
		{
			// Update PerfMon Results box
			richBox_Results.Clear();
			richBox_Results.Text = _Context.PerfStats.ToString();

			// Update PerfMon History box
			richBox_History.Clear();
			richBox_History.Text = "History (Last 5 executions):";
			foreach (TimeSpan prev in _Context.PerfStats.Previous)
			{
				// For comparison's sake, always use milliseconds in the History window
				richBox_History.Text += "\r\n" + prev.TotalMilliseconds.ToString() + "ms";
			}
		}

		
	}
}
